<?php
$match = Frontend::findMatchByTimeStamp((int) $_today)->limit(6);
$match_tamdiem = Frontend::findMatchByLevel((int) $_today, 0, "desc")->limit(6);
//$news = Frontend::findAllNews()->limit(6);
//$adbo = &ADONewConnection('mysql');
//$cnn  = $adbo->PConnect("123.30.169.203", "root", "minhtrang123", "vfm_yeuthethao");
$conn = &ADONewConnection('mysql');
$conn->Connect("123.30.169.203", "root", "minhtrang123", "vfm_yeuthethao");
$GLOBALS['con'] = $conn;
$GLOBALS['con']->execute("set names utf8");
$news = $GLOBALS['con']->execute("select * from articles where flag=1 order by id desc limit 10");
?>
<div class="thumbnail">
    <div class="caption">
        <ul style="text-transform:uppercase;" class="nav nav-tabs tab">
            <li class="active">
                <a data-toggle="tab" href="#tam-diem">Trận tâm điểm</a>
            </li>
            <li class="">
                <a data-toggle="tab" href="#sap">Bóng đá</a>
            </li>
            <li class="">
                <a data-toggle="tab" href="#cacmonkhac">Các môn khác</a>
            </li>
        </ul>
        <div class="tab-content">
            <div style="background:#fff; padding-bottom: 10px;" class="tab-pane fade active in" id="tam-diem">
                <ul class="tb">
                    <li class="tb-tit">
                        <div class="tb-tit-tg">Thời gian</div>
                        <div class="tb-tit-team">&nbsp;</div>
                        <div></div>
                    </li>
                    <?php
                    foreach ($match_tamdiem as $_match) {
                        $team1 = Frontend::findTeamById((int) $_match["Team1"]);
                        $team2 = Frontend::findTeamById((int) $_match["Team2"]);
                        $link_match = Frontend::findTournamentById((int) $_match["TourID"]);

                        foreach ($team1 as $_team1)
                            $t1 = $_team1["name"];
                        foreach ($team2 as $_team2)
                            $t2 = $_team2["name"];

                        $str_team = trim(Core::str_process($t1 . " " . $t2));
                        $link_team = strtolower(preg_replace('/[^a-z0-9]+/i', '-', $str_team));
                        ?>
                        <li class="tb-body">
                            <div class="tb-tit-tg"><?php echo date("d/m/Y h:i", $_match["DateMatchTS"]); ?></div>
                            <div class="tb-tit-team" style="text-align: left">
                            <!--<img src="images/1c6DAzIKZcZAHjCCDtbP.png" width="30px"/>-->
                                <?php foreach ($link_match as $_link_match) { ?>
                                    <a href="<?php echo SKIN_FPATH . "dudoan/" . $_link_match["location"] . "/" . $link_team . "/" . $_match["_id"] ?>">
                                        <?php echo $t1 . " - " . $t2; ?>
                                    </a>
                                <?php } ?>
                    <!--<img src="images/3blMGNMkgWCqQ6swsOtp.png" width="30px"/>-->
                            </div>
                            <div style="width: 10px;">
                                <?php foreach ($link_match as $_link_match) { ?>
                                    <a href="<?php echo SKIN_FPATH . "dudoan/" . $_link_match["location"] . "/" . $link_team . "/" . $_match["_id"] ?>">
                                        <img style="max-width: none !important;" src="<?php echo SKIN_FPATH ?>skin/frontend/icon/red.png">
                                    </a>
                                <?php } ?>
                            </div>
                        </li>
                    <?php } ?>
                </ul>
            </div>
            <!-- Sắp diễn ra-->
            <div class="tab-pane fade" id="sap">
                <ul class="tb">
                    <li class="tb-tit">
                        <div class="tb-tit-tg">Thời gian</div>
                        <div class="tb-tit-team">&nbsp;</div>
                        <div></div>
                    </li>
                    <?php
                    foreach ($match as $_match) {
                        $team1 = Frontend::findTeamById((int) $_match["Team1"]);
                        $team2 = Frontend::findTeamById((int) $_match["Team2"]);
                        $link_match = Frontend::findTournamentById((int) $_match["TourID"]);

                        foreach ($team1 as $_team1)
                            $t1 = $_team1["name"];
                        foreach ($team2 as $_team2)
                            $t2 = $_team2["name"];

                        $str_team = trim(Core::str_process($t1 . " " . $t2));
                        $link_team = strtolower(preg_replace('/[^a-z0-9]+/i', '-', $str_team));
                        ?>
                        <li class="tb-body">
                            <div class="tb-tit-tg" style="margin-top: 8px"><?php echo date("d/m/Y h:i", $_match["DateMatchTS"]); ?></div>
                            <div class="tb-tit-team" style="text-align: left">
                            <!--<img src="images/1c6DAzIKZcZAHjCCDtbP.png" width="30px"/>-->
                                <?php foreach ($link_match as $_link_match) { ?>
                                    <a href="<?php echo SKIN_FPATH . "dudoan/" . $_link_match["location"] . "/" . $link_team . "/" . $_match["_id"] ?>">
                                        <?php echo $t1 . " - " . $t2; ?>
                                    </a>
                                <?php } ?>
                <!--<img src="images/3blMGNMkgWCqQ6swsOtp.png" width="30px"/>-->
                            </div>
                            <div style="width: 10px;">
                                <?php foreach ($link_match as $_link_match) { ?>
                                    <a href="<?php echo SKIN_FPATH . "dudoan/" . $_link_match["location"] . "/" . $link_team . "/" . $_match["_id"] ?>">
                                        <img style="max-width: none !important;" src="<?php echo SKIN_FPATH ?>skin/frontend/icon/red.png">
                                    </a>
                                <?php } ?>
                            </div>
                        </li>
                    <?php } ?>
                </ul>
            </div>
            <div class="tab-pane fade" id="cacmonkhac">
                <ul class="tb">
                    <li class="tb-tit">
                        Đang cập nhật
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div><div class="thumbnail">
    <div class="caption">
        <ul style="text-transform:uppercase;" class="nav nav-tabs tab">
            <li class="active"><a data-toggle="tab" href="#tin-tuc">Bản tin dự đoán</a></li>
            <!--<li class=""><a data-toggle="tab" href="#tieu-diem">Tiêu điểm</a></li>-->
        </ul>
        <div style="margin-top:-3px;" class="tab-content">
            <div style="background:#fff; padding-bottom: 10px;margin-top:5px;position:relative;margin-bottom: 50px;" class="tab-pane fade active in" id="tin-tuc">
                <?php
                foreach ($news as $_news) {
                    $str_news = trim(Core::str_process($_news["name"]));
                    $link_news = strtolower(preg_replace('/[^a-z0-9]+/i', '-', $str_news));
                    $category = $GLOBALS['con']->execute("select * from category where id={$_news["cate_id"]}");
                    foreach ($category as $_category) {
                        ?>
                        <div class="media bg-media box-bg-media">
                            <a target="_blank" href="http://tttv.vn/<?php echo $_category["safe_title"] . "/" . $link_news . "-" . $_news["id"] . ".html" ?>" class="pull-left">
                                <img class="media-object" src="http://tttv.vn/images/<?php echo $_news["image"] ?>">
                            </a>
                            <div class="media-body">
                                <h5 class="media-heading">
                                    <a target="_blank" class="tit2" href="http://tttv.vn/<?php echo $_category["safe_title"] . "/" . $link_news . "-" . $_news["id"] . ".html" ?>">
                                        <?php echo $_news["name"] ?>
                                    </a>
                                </h5>
                                <p class="date"><?php echo date("d-m-Y h:i", $_news["create_date"]) ?></p>
                            </div>
                        </div>
                        <?php
                    }
                }
                ?>
            </div>
        </div>
    </div>
</div> 